//
//  HeadlineController.m
//  Village
//
//  Created by 程虎 on 2017/9/1.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "HeadlineController.h"
#import "ChildViewController.h"

@interface HeadlineController ()

@end

@implementation HeadlineController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"村头条";
    
    // 模仿网络延迟，0.2秒后，才知道有多少标题
//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    
        // 移除之前所有子控制器
        [self.childViewControllers makeObjectsPerformSelector:@selector(removeFromParentViewController)];
    
        // 把对应标题保存到控制器中，并且成为子控制器，才能刷新
        // 添加所有新的子控制器
        [self setUpAllViewController];
//    });

    [self setUpTitleEffect:^(UIColor *__autoreleasing *titleScrollViewColor, UIColor *__autoreleasing *norColor, UIColor *__autoreleasing *selColor, UIFont *__autoreleasing *titleFont, CGFloat *titleHeight, CGFloat *titleWidth) {
        *titleScrollViewColor = [Util colorWithHexString:@"#f54f33"];
        *titleHeight = kNavHeight;
        *norColor = [UIColor whiteColor];
        *selColor = [UIColor whiteColor];
    }];
    
    // 标题渐变
    // *推荐方式(设置标题渐变)
    [self setUpTitleGradient:^(YZTitleColorGradientStyle *titleColorGradientStyle, UIColor *__autoreleasing *norColor, UIColor *__autoreleasing *selColor) {
        
    }];
    
    // 字体缩放
    // 推荐方式 (设置字体缩放)
    [self setUpTitleScale:^(CGFloat *titleScale) {
        // 字体缩放比例
        *titleScale = 1.3;
    }];
}

// 添加所有子控制器
- (void)setUpAllViewController
{
    ChildViewController *wordVc1 = [[ChildViewController alloc] init];
    wordVc1.title = @"农村生活";
    [self addChildViewController:wordVc1];
    
    ChildViewController *wordVc2 = [[ChildViewController alloc] init];
    wordVc2.title = @"情感交友";
    [self addChildViewController:wordVc2];
    
    ChildViewController *wordVc3 = [[ChildViewController alloc] init];
    wordVc3.title = @"致富有道";
    [self addChildViewController:wordVc3];
    
    ChildViewController *wordVc4 = [[ChildViewController alloc] init];
    wordVc4.title = @"特产美食";
    [self addChildViewController:wordVc4];
    
    ChildViewController *wordVc5 = [[ChildViewController alloc] init];
    wordVc5.title = @"农村旅游";
    [self addChildViewController:wordVc5];
    
    ChildViewController *wordVc6 = [[ChildViewController alloc] init];
    wordVc6.title = @"劳务信息";
    [self addChildViewController:wordVc6];
    
    ChildViewController *wordVc7 = [[ChildViewController alloc] init];
    wordVc7.title = @"寻人寻物";
    [self addChildViewController:wordVc7];
    
    LSLog(@"子控制器 --------- %ld",self.childViewControllers.count);
}

@end
